<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>公司名称管理</title>
<base href="<%=basePath%>">

<link rel="stylesheet" href="static/ace/css/bootstrap.css" />
<link rel="stylesheet" href="static/ace/css/font-awesome.css" />
<link rel="stylesheet" href="static/ace/css/ace-fonts.css" />
		<link rel="stylesheet" href="static/ace/css/ace-fonts.css" />
<link rel="stylesheet" href="static/ace/css/ace.css"
	class="ace-main-stylesheet" id="main-ace-style" />

<script type="text/javascript" src="static/js/jquery-1.7.2.js">
	<script type="text/javascript">
	$(top.hangge());
</script>
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</head>
<body>

<form class="form-horizontal"  id="companyForm">
                    <fieldset>
                       
                        <div
				style="width: 200px; height: 30px; margin: 15px auto;  font-size: 25px">公司名称管理</div>
                       <div class="form-group">
                          <label class="col-sm-1 control-label" >公司名称</label>
                          <div class="col-sm-5">
                             <input class="form-control" name="COMPANY_NAME"  id="COMPANY_NAME"  value="" type="text" placeholder="请输入公司名称"/>
                          </div>
                          <label class="col-sm-1 control-label" >公司代码</label>
                          <div class="col-sm-5">
                             <input class="form-control" name="COMPANY_CODE" id="COMPANY_CODE" type="text" placeholder="请输入公司代码"/>
                          </div>
                       </div>
                   
                   <div style="margin:15px auto; width:200px;">
                   
                    <input style="margin:10px;" type="button" value="添加" onclick="add()"/>
                     
                   </div>
                       	

                    </fieldset>     
                </form>
                <div>
                <form method="post" >
                 <div class="form-group"> 
                          <label class="col-sm-1 control-label" >公司名称</label>
                          <div class="col-sm-3">
                             <input class="form-control" name="COMPANY_NAME" type="text"  value="${pd.COMPANY_NAME}" placeholder="请输入公司名称"/>
                          </div>
                          <div style="margin:2px 4px 3px 550px;">
                              <input  type="submit" value="查询" />
                          </div>
                       </div>
                </form>
                </div>
                
           <div>
           <table class="table table-striped table-bordered table-hover">
          <thead>
				<tr>
				<th class="center" style="width: 30px;">
									<label class="pos-rel"><input type="checkbox" class="ace" id="selectAll" /><span class="lbl"></span></label>
									</th>
					<th class="center">公司名称</th>
					<th class="center">公司代码</th>
					<th class="center">修改</th>
					<th class="center">删除</th>
				</tr>
			</thead>
           	<c:forEach items="${list}" var="company">          	
           	<tr>
                       	<td class="center" style="width: 30px;">
							<label><input type='checkbox' value="${company.ID }"  /><span class="lbl"></span></label>
							</td>
					<td class="center">${company.COMPANY_NAME}</td>
					<td class="center">${company.COMPANY_CODE }</td>            
					<td class="center"><a onclick="edit('${company.ID}')">修改</a></td>
					<td class="center"><a onclick="delet('${company.ID}')">刪除</a></td>

				</tr>
           	
           	</c:forEach>
           
           </table>
           
           
           </div>
</body>
<script type="text/javascript">
function add(){
	if($("#COMPANY_NAME").val()==""){
		$("#COMPANY_NAME").tips({
			side:3,
            msg:'请填写公司名称',
            bg:'#AE81FF',
            time:2
        });
		$("#COMPANY_NAME").focus();
		$("#COMPANY_NAME").val('');
		$("#COMPANY_NAME").css("background-color","white");
		return false;
	}
	
	if($("#COMPANY_CODE").val()==""){
		$("#COMPANY_CODE").tips({
			side:3,
            msg:'请填写公司代码',
            bg:'#AE81FF',
            time:2
        });
		$("#COMPANY_CODE").focus();
		$("#COMPANY_CODE").val('');
		$("#COMPANY_CODE").css("background-color","white");
		return false;
	}
	$.ajax({
		type:"post",
		url: '<%=basePath%>company/addcompany',
		data:$("#companyForm").serialize(),
		dataType:"text",
		success: function(data){
			alert("保存成功")
			 window.location.reload();
		}
		
	});
	
	
};
//修改
function edit(ID){
	
	 top.jzts();
     var diag = new top.Dialog();
     diag.Drag = true;
     diag.Title = "编辑";
     diag.URL = '<%=basePath%>company/edit?ID=' + ID;
     diag.Width = 400;
     diag.Height = 250;
     diag.CancelEvent = function () { //关闭事件
     	diag.close();
     	window.location.reload();	
     };
     diag.show();
	
	
}

//删除
function delet(ID){
	if (confirm("确认要删除本条信息！")){
		$.ajax({
			type:"post",
			url:'<%=basePath%>company/deleteU?ID='+ID,
			success:function(){
				window.location.reload();
			}
			
		})
		return false;
		}
	
	
	
}


	
	

</script>
</html>